package com.sixth.statistics.controller;

import com.sixth.core.entity.Comment;
import com.sixth.core.vo.R;
import com.sixth.statistics.service.CommentService;
import com.sixth.statistics.vo.CommentVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;

@Api(tags = "评论统计")
@RestController
@RequestMapping("/statistics/comment")
public class CommentController {

    @Autowired
    private CommentService commentService;

    @ApiOperation(value = "获取评论分页列表", notes = "根据传入的 CommentVo 对象获取分页评论列表")
    @PostMapping("/listPage")
    public R<IPage<Comment>> list(@RequestBody CommentVo commentVo) {
        return commentService.selectAll(commentVo);
    }

    @ApiOperation(value = "删除单条评论", notes = "根据评论 ID 删除单条评论")
    @GetMapping("/delete/{id}")
    public R delete(@PathVariable Integer id) {
        return commentService.deleteById(id);
    }

    @ApiOperation(value = "批量删除评论", notes = "根据评论 ID 数组批量删除评论")
    @GetMapping("/batchDelete")
    public R batchDelete(@RequestParam Integer[] id) {
        return commentService.deleteList(id);
    }
}
